package com.rocksea.app.db.history;

import com.litesuits.orm.db.annotation.Column;
import com.litesuits.orm.db.annotation.PrimaryKey;
import com.litesuits.orm.db.annotation.Table;
import com.litesuits.orm.db.enums.AssignType;
import com.rocksea.app.db.HighStrain.HighStrain;
import com.rocksea.app.db.SonicWave.SonicWave;
import com.rocksea.app.db.StaticLoad.StaticLoad;
import com.rocksea.app.db.lowStrain.LowStrainDb;
import com.rocksea.app.entry.DyData;
import com.rocksea.app.entry.TestData;


import java.util.Date;


/**
 * Created by 吴志华 on 2017/7/28.
 * 历史记录表数据库结构
 */

@Table("History")
public class HistoryTable{

    /**
     * 0-低应变
     * 1-高应变
     * 2-声波
     * 3-静载
     * */
    public static final int TEST_DY = 0;
    public static final int TEST_GY = 1;
    public static final int TEST_SC = 2;
    public static final int TEST_JZ = 3;
    public static final int TEST_ALL = 4;

    public static final int JY_SAMPLE_DATA = 5;
    public static final int JY_LOG_DATA = 6;


    @PrimaryKey(AssignType.AUTO_INCREMENT)
    @Column("id")
    public int id;                          //数据ID
    public String BaseInfoId;               //UUID
    public long CreatTime;                  //数据接收时间
    public int Type;                        //实验类型
    public int IsLoad;                      //是否上传
    public String SerialNo;                 //流水号
    public long LoadTime;                   //上传时间
    public int remoteId;
    public String getTestTime()
    {
        return testTime;
    }
    public void setTestTime(String testTime) {
        this.testTime = testTime;
    }
    private String testTime;

    public String getSerialNo(){
        return SerialNo;
    }
    public int getType() {
        return Type;
    }
    public int getTestMode() {
        return TestMode;
    }
    @Column("TestMode")
    public int TestMode;
    public String getPileNo() {
        return PileNo;
    }

    public int getRemoteId() {
        return remoteId;
    }

    public void setRemoteId(int remoteId) {
        this.remoteId = remoteId;
    }

    public int getIsLoad(){
        return IsLoad;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setBaseInfoId(String baseInfoId) {
        BaseInfoId = baseInfoId;
    }

    public void setCreatTime(long creatTime) {
        CreatTime = creatTime;
    }

    public void setType(int type) {
        Type = type;
    }

    public void setIsLoad(int isLoad) {
        IsLoad = isLoad;
    }

    public void setSerialNo(String serialNo) {
        SerialNo = serialNo;
    }

    public void setLoadTime(long loadTime) {
        LoadTime = loadTime;
    }

    public void setTestMode(int testMode) {
        TestMode = testMode;
    }

    public void setPileNo(String pileNo) {
        PileNo = pileNo;
    }

    @Column("PileNo")
    public String PileNo;
    public HistoryTable()
    {

    }
    //测试用
    public HistoryTable(String baseInfoId, long creatTime, int type, int isLoad, String serialNo) {
        BaseInfoId = baseInfoId;
        CreatTime = creatTime;
        Type = type;
        IsLoad = isLoad;
        SerialNo = serialNo;
    }


    public HistoryTable(TestData mData){
        BaseInfoId = mData.getBaseInfoId();
        CreatTime = mData.getReceivedDate().getTime();
        Type = mData.getTestMode();
        IsLoad = 0;
        SerialNo = mData.getSeialNo();
        PileNo = mData.getPileNo();
        TestMode = mData.getTestMode();
        remoteId = mData.getRemoteId();
        testTime = mData.getTestTime();
    }

    public HistoryTable(LowStrainDb lowStrain)
    {
        BaseInfoId = lowStrain.uuid;
        CreatTime = new Date().getTime();
        Type =HistoryTable.TEST_DY;
        IsLoad = 0;
        SerialNo = lowStrain.serialNo;
        PileNo = lowStrain.pileNo;
        TestMode = -1;
        remoteId = 0;
        testTime = lowStrain.startTime;
    }

    public HistoryTable(DyData dyData)
    {
        BaseInfoId = dyData.BaseInfoId;
        CreatTime = new Date().getTime();
        Type =HistoryTable.TEST_DY;
        IsLoad = 0;
        SerialNo = dyData.SerialNo;
        PileNo = dyData.PileNo;
        TestMode = -1;
        remoteId = 0;
        testTime = dyData.StartTime;
    }


    public HistoryTable(SonicWave sonicWave)
    {
        BaseInfoId = sonicWave.uuid;
        CreatTime = new Date().getTime();
        Type =HistoryTable.TEST_SC;
        IsLoad = 0;
        SerialNo = sonicWave.serialNo;
        PileNo = sonicWave.pileNo;
        TestMode = -1;
        remoteId = 0;
        testTime = sonicWave.startTime;
    }

    public HistoryTable(StaticLoad staticLoad)
    {
        BaseInfoId = staticLoad.baseInfoId;
        CreatTime = new Date().getTime();
        Type = HistoryTable.TEST_JZ;
        IsLoad = 0;
        SerialNo = staticLoad.serialNo;
        PileNo = staticLoad.pileNo;
        TestMode = -1;
        remoteId = 0;
        testTime = staticLoad.startTime;
    }
    public HistoryTable(HighStrain highStrain)
    {
        BaseInfoId = highStrain.uuid;
        CreatTime = new Date().getTime();
        Type =HistoryTable.TEST_GY;
        IsLoad = 0;
        SerialNo = highStrain.serialNo;
        PileNo = highStrain.pileNo;
        TestMode = -1;
        remoteId = 0;
        testTime = highStrain.startTime;
    }
}
